﻿using System;
using System.Collections.Generic;
namespace Host
{
	public class StatusData : IComponents
	{
        public StatusData()
		{
		}

		public Dictionary<string, object> data_mapping = new Dictionary<string, object>();

		[IComponentsMethodAttribute()]
		public object ShowAllData(string text1, string text2 = "AAA")
		{
			var text = LitJson.JsonMapper.ToJson(data_mapping);

			SetData("Text1", text1);
			SetData("Text2", text2);

			return text;
		}

		/// <summary>
		/// 获取数据
		/// </summary>
		/// <returns>The data.</returns>
		/// <param name="name">Name.</param>
		/// <typeparam name="T">The 1st type parameter.</typeparam>
		public T GetData<T>(string name)
		{
			if (!data_mapping.ContainsKey(name))
				return default(T);

			return (T)data_mapping[name];
		}

		/// <summary>
		/// 设置数据
		/// </summary>
		/// <param name="name">Name.</param>
		/// <param name="value">Value.</param>
		public void SetData(string name, object value)
		{
			data_mapping[name] = value;
		}

	}
}
